package com.FaceThingThird.InnterClass4;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Test {
    public static void main(String[] args) {
        //匿名内部类在开发中的真实使用场景
        //GUI编程
        //1.创建窗口
        JFrame win=new JFrame("登陆界面");
        JPanel panel=new JPanel();//桌布
        win.add(panel);
        JButton btn=new JButton("登录");
        panel.add(btn);
        //win.add(btn);
        //给按钮绑定单击事件监听器
//        btn.addActionListener(new ActionListener() {
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                JOptionPane.showConfirmDialog(win,"登陆一下");
//            }
//        });
        //匿名内部类：最终目的是简化代码。
        btn.addActionListener(e ->   JOptionPane.showConfirmDialog(win,"登陆一下"));




        win.setSize(700,700);
        win.setLocationRelativeTo(null);
        win.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        win.setVisible(true);
    }
}
